package com.hullunyingshi.until;

import java.io.Serializable;

/**
 * @author dpf
 *  * @QQ 792442257
 * @description 
 * @createDate 2018年4月28日
 */
public class PageHelper implements Serializable {

	private Integer curPage;
	private Integer totalPage = 0;
	private Integer pageSize = 20;
	private Integer totalCount = 0;

	public PageHelper(Integer curPage, Integer pageSize, Integer totalCount) {
		super();
		this.curPage = curPage;
		this.pageSize = pageSize;
		this.totalCount = totalCount;
	}

	private Object data;

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Integer getCurPage() {
		return curPage;
	}

	public void setCurPage(Integer curPage) {
		this.curPage = curPage;
	}

	public void setTotalPage(Integer totalPage) {
		this.totalPage = totalPage;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(Integer totalCount) {
		this.totalCount = totalCount;
	}

	public static Integer getStartIndex(Integer pageNum, Integer pageSize) {
		Integer res = 0;
		if (pageNum > 0) {
			res = (pageNum - 1) * pageSize;
		}
		return res;
	}

	public int getTotalPage() {
		if (totalCount % pageSize == 0) {
			totalPage = totalCount / pageSize;
		} else {
			totalPage = (totalCount / pageSize) + 1;
		}
		return totalPage;
	}

}
